<template>
	<div>

		<view class='data-item' @click='detail(item)' v-for="(item,idx) in dataList" :key="idx" >
	        <view class='data-img'>
	          
	            <img style='width:180rpx;height:150rpx;' :src="item.absoluteurl">
	        </view>
	        <view class='data-desc'>
	            <view>{{pageText.jqbh}}：<text>{{item.code}}</text></view>
	            <view>{{pageText.jqmc}}：<text>{{item.name}}</text></view>
	            <view>{{pageText.jqwz}}：<text v-if="item.location" >{{item.location}}</text></view>
	            <view>{{pageText.hzsj}}：<text>{{stime}} ~ {{etime}}</text></view>
	        </view>
    	</view>
	</div>
</template>
<script type="text/javascript">
	import {get} from '../../utils/index'
	export default{
		
		data() {
			return {
				
				loading:true,
				dataList:[],
				stime:'',
				etime:'',
				userid:0,
				usertype:0,
				pageText:{
						'title':'我的咖缘吧',
						'jqbh':'机器编号',
						'jqmc':'机器名称',
						'jqwz':'机器位置',
						'hzsj':'合作时间',
						'mysj':'没有数据'

			  }
			}
		},
		async mounted(){
			this.userid = this.$root.$mp.query.userid;
			this.usertype = this.$root.$mp.query.usertype;
			this.getDataList();
		},
		methods:{
			detail(item){
				console.log(item)
				var  item = JSON.stringify(item);
				
				wx.navigateTo({
          url: '/pages/coffeeMenu/main?item='+item,
				})
			},
			async getDataList(){
				var id = 0;
      			var usertype = 0;
      			var user = wx.getStorageSync('userDo')
      			this.loading = true
      			if (this.userid){
			        id = this.userid;
			        usertype = this.usertype;
			    }else{
			        id = user.userId
			        usertype = user.type
			    }

			    var datas = {
			    	type: usertype,
	                userId: id,
	                offset: 0,
	                limit:9999
			    };
			    this.dataList = await get('getMakerListByUserId',datas);
			}
		}
	}
</script>

<style>
page{
    background: #f5f5f5;
    height: 100%;
}
.data-list{
    height: 100%;
}
.data-item{
    display: flex;
    padding: 20rpx;
    margin: 30rpx 20rpx;
    background: #fff;
    box-shadow: 2rpx 2rpx 4rpx #ccc;
}
.data-img image{
    border-radius: 10rpx;
}
.data-img  text{
    display: block;
    font-size: 26rpx;
    text-align: center;
}
.data-desc{
    font-size: 22rpx;
    padding-left: 20rpx;
    
}
.data-desc view{
    margin-bottom: 10rpx;
}
.data-desc view text{
    color: #888888
}

</style>